<?php

class logger extends Module {
	var $module_name = "logger";
	var $module_version = 0.1;
	var $module_description = "Goal of this module is to handle logging data from client's to services database";

	var $client = "common";
	var $client_version = "latest";

	function __construct() {
		parent::__construct();
	}

	function run() {
		try {
			if ( isset($_GET["client"]) ) 	$this->client = filter_var($_GET["client"],FILTER_SANITIZE_STRING);
			if ( isset($_GET["version"]) )	$this->version = filter_var($_GET["client"],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);


			$client_api_filename = sprintf("modules/%s/%.1f/clients/%s_%s.php",$this->module_name, $this->module_version, $this->client, $this->client_version);
			$logger_api_filename = sprintf("modules/%s/%.1f/CommonClient.class.php",$this->module_name, $this->module_version);

	
			if ( file_exists($logger_api_filename) ) {
				require_once($logger_api_filename);
			} else {
				Header($_SERVER["SERVER_PROTOCOL"]." 500 Internal Server Error");
				print "Could not locate logger API.";
				exit;
			}
	
			if ( file_exists($client_api_filename) ) {
				require_once($client_api_filename);
				} else {
				Header($_SERVER["SERVER_PROTOCOL"]." 500 Internal Server Error");
				print "Could not locate client API definitions.";
				exit;
			}
	
			if ( class_exists("Client") ) {
				$client = new Client();
			} else {
				Header($_SERVER["SERVER_PROTOCOL"]." 500 Internal Server Error");
				print "Could not create new Client instance for you.";
				exit;
			}
		} catch (Exception $e) {
			Header($_SERVER["SERVER_PROTOCOL"]." 500 Internal Server Error");
			echo 'Caught exception: ',  $e->getMessage(), "\n";
			exit;
	
		}
	}


}

?>
